package com.juli.school.service.enums;

import java.util.Arrays;
import com.juli.school.dao.entity.Pub;
import com.juli.school.service.CommonService;
import com.juli.school.service.utils.SpringContextHolder;

/**
 * @Description: 模块枚举常量
 * @author gaoxiang
 * @date 2017年11月17日 下午3:13:24
 */ 
public enum EnumModule {
	
	Miss("miss","失物招领"),
	Find("find","寻物启事"),
	News("news","新闻中心"),
	Contest("contest","竞赛活动"),
	Group("group","社团介绍"),
	GroupSms("groupSms","社团活动"),
	Love("love","爱心捐助"),
	Job("job","校园兼职"),
	Mall("mall","闪购"),
	Leg("leg","代跑腿"),
	Er("er","闲置交易"),
	Smart("smart","智力众筹"),
	;
	
	public String code;
	
	public String module;
	
	public Class<? extends CommonService<? extends Pub>> service;

	private EnumModule(String code, String module) {
		this.code = code;
		this.module = module;
	}
	
	public static EnumModule codeOf(String code) {
		return Arrays.asList(EnumModule.values()).stream().filter(enumModule -> enumModule.code.equals(code)).findFirst().orElse(null);
	}
	
	public CommonService<? extends Pub> getService() {
		return SpringContextHolder.getBean(this.service);
	}
}
